﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace PominaScale.DataAccess
{
    public interface IBaseDataAccess<T>
    {

        #region A Search Object and Methods
        /// <summary>
        /// Search object property. To contain values to filter.
        /// </summary>
        [Category("Search")]
        T SearchObject { get; set; }

        /// <summary>
        /// Search method. Occurs filter.
        /// </summary>
        /// <returns></returns>
        [Category("Search")]
        IList<T> Search(); 
        #endregion

        #region Get Methods
        /// <summary>
        /// Get last record.
        /// </summary>
        /// <returns></returns>
        [Category("GetLast")]
        T GetLast();

        /// <summary>
        /// Get all records.
        /// </summary>
        /// <returns></returns>
        [Category("Get")]
        IList<T> GetAll();

        /// <summary>
        /// Get all records with active value is true.
        /// </summary>
        /// <returns></returns>
        [Category("Get")]
        IList<T> GetAllActive(); 
        #endregion

        #region Add New Method
        /// <summary>
        /// Add new an item method.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [Category("Add")]
        bool Add(T item);

        /// <summary>
        /// Add new items collection method.
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        [Category("Add")]
        bool Add(IList<T> collection, out int success, out int failed); 
        #endregion

        #region Edit Methods
        /// <summary>
        /// Edit an item method.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [Category("Edit")]
        bool Edit(T item);

        /// <summary>
        /// Edit items collection method.
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        [Category("Edit")]
        bool Edit(IList<T> collection, out int success, out int failed); 
        #endregion

        #region Save Method
        /// <summary>
        /// Process many statuses, such as: IsNew, IsDelete and IsEdit.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [Category("Save")]
        bool Save(IList<T> collection, out int success, out int failed); 
        #endregion

        #region Delete Methods
        /// <summary>
        /// Delete an item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        [Category("Delete")]
        bool Delete(T item);

        /// <summary>
        /// Delete items collectin method.
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        [Category("Delete")]
        bool Delete(IList<T> collection, out int success, out int failed); 
        #endregion

    }
}
